Java Namespace类代码示例

您所在的位置:网站首页 dom4j namespace Java Namespace类代码示例

Java Namespace类代码示例

#Java Namespace类代码示例| 来源: 网络整理| 查看: 265

本文整理汇总了Java中org.dom4j.Namespace的典型用法代码示例。如果您正苦于以下问题:Java Namespace类的具体用法?Java Namespace怎么用?Java Namespace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

Namespace类属于org.dom4j包,在下文中一共展示了Namespace类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: toDsml import org.dom4j.Namespace; //导入依赖的package包/类 /** * {@inheritDoc} */ @Override public Element toDsml( Element root ) { Element element = super.toDsml( root ); // Request Name if ( getDecorated().getRequestName() != null ) { element.addElement( "requestName" ).setText( getDecorated().getRequestName() ); } // Request Value Namespace xsdNamespace = new Namespace( "xsd", ParserUtils.XML_SCHEMA_URI ); Namespace xsiNamespace = new Namespace( "xsi", ParserUtils.XML_SCHEMA_INSTANCE_URI ); element.getDocument().getRootElement().add( xsdNamespace ); element.getDocument().getRootElement().add( xsiNamespace ); Element valueElement = element.addElement( "requestValue" ).addText( ParserUtils.base64Encode( getRequestValue() ) ); valueElement.addAttribute( new QName( "type", xsiNamespace ), "xsd:" + ParserUtils.BASE64BINARY ); return element; } 开发者ID:apache,项目名称:directory-ldap-api,代码行数:29,代码来源:ExtendedRequestDsml.java 示例2: toString import org.dom4j.Namespace; //导入依赖的package包/类 /** * String representation of the ComplexType object * * @return a String representation of the ComplexType object */ public String toString() { String s = "ComplexType: " + getName(); String nl = "\n\t"; s += nl + "type: " + getType(); s += nl + "location: " + getLocation(); s += nl + "contentmodel: " + getContentModel(); if (getNamespace() != Namespace.NO_NAMESPACE) s += nl + "namespace: " + getNamespace().getPrefix() + ": " + getNamespace().getURI(); else s += nl + "namespace: null"; // s += nl + "modelGroup: " + modelGroup; // s += nl + "there are " + getChildren().size() + " content elements"; /* * if (modelGroup == null) * s += "\n" + element.asXML(); */ s += nl + "schemaNamespace: " + this.getSchemaReader().getNamespaces().getSchemaNamespace().getPrefix(); s += Dom4jUtils.prettyPrint(getElement()); return s; } 开发者ID:NCAR,项目名称:joai-project,代码行数:26,代码来源:ComplexType.java 示例3: toString import org.dom4j.Namespace; //导入依赖的package包/类 /** * Description of the Method * *@return Description of the Return Value */ public String toString() { String s = "SimpleType: " + getName(); s += "\n\t location: " + getLocation(); if (isEnumeration()) { s += "\n\tEnumeration"; for (Iterator i = getSimpleEnumerationValues().iterator(); i.hasNext(); ) { s += "\n\t\t" + (String) i.next(); } } else if (isUnion()) { s += "\n\tUnion (" + getUnionMemberTypesAsString() + ")"; } else { s += getElement().asXML(); } if (getNamespace() != Namespace.NO_NAMESPACE) s += "\n\tnamespace: " + getNamespace().getPrefix() + ": " + getNamespace().getURI(); else s += "\n\tnamespace: null"; return s; } 开发者ID:NCAR,项目名称:joai-project,代码行数:27,代码来源:SimpleType.java 示例4: getNamespaceForPrefix import org.dom4j.Namespace; //导入依赖的package包/类 /** * Search the stack (moving from local to more global SchemaReaders) for the namespace * belonging to the given prefix. */ public Namespace getNamespaceForPrefix (String prefix) { Namespace ns = Namespace.NO_NAMESPACE; prtln ("\n\tReaderStack.getNamespace() looking for prefix: " + prefix); for (int i=0; i < size(); i++) { SchemaReader sr = getItemAt(i); prtln ("\t\t " + sr.getLocation()); NamespaceRegistry namespaceContext = sr.getNamespaces(); ns = namespaceContext.getNSforPrefix(prefix); if (!ns.getPrefix().equals("")) { prtln ("\t\t\t ... found namespace -- " + ns.getPrefix() + ": " + ns.getURI()); break; } } return ns; } 开发者ID:NCAR,项目名称:joai-project,代码行数:20,代码来源:ReaderStack.java 示例5: resolveQName import org.dom4j.Namespace; //导入依赖的package包/类 /** * Tries to resolve give QName into a "top-level" namespace and prefix. If the * there is no prefix and the namespace is the default namespace, assign the * NAMED defaultNamespace. * * @param qName Description of the Parameter * @return Description of the Return Value * @exception Exception Description of the Exception */ private QName resolveQName(QName qName) throws Exception { String prefix = qName.getNamespacePrefix(); String name = qName.getName(); String uri = qName.getNamespaceURI(); prtln("\n\t resolveQName: ", 1); prtln("\t\t name: " + name, 1); prtln("\t\t prefix: " + prefix, 1); prtln("\t\t uri: " + uri, 1); Namespace topLevelNS = namespaces.getNSforUri(uri); if (topLevelNS == null) { prtlnErr("ERROR: resolveQName could not find top-level namespace for " + uri); return null; } else if (topLevelNS == namespaces.getDefaultNamespace()) { topLevelNS = namespaces.getNamedDefaultNamespace(); } return df.createQName(name, topLevelNS); } 开发者ID:NCAR,项目名称:joai-project,代码行数:29,代码来源:StructureWalker.java 示例6: createChildElement import org.dom4j.Namespace; //导入依赖的package包/类 /** * Resolve qualified name against top-level namespace registry * * @param name NOT YET DOCUMENTED * @return NOT YET DOCUMENTED */ private Element createChildElement(String name) { prtln("\n createChildElement() name: " + name, 1); Namespace ns = getCurrentNamespace(); prtln("\t currentNamespace -- " + ns.getPrefix() + ": " + ns.getURI(), 1); Element child = null; if (ns == null || !namespaceEnabled) { child = df.createElement(name); } else { QName baseQName = df.createQName(name, ns); try { child = df.createElement(resolveQName(baseQName)); } catch (Exception e) { prtlnErr("createChildElement error: " + e.getMessage()); e.printStackTrace(); return null; } } prtln(" ... child: " + child.asXML(), 1); return child; } 开发者ID:NCAR,项目名称:joai-project,代码行数:28,代码来源:StructureWalker.java 示例7: processSubstitutionGroup import org.dom4j.Namespace; //导入依赖的package包/类 /** * this method will indeed insert the right elements, but we do we want them * in the instance document?? i'm thinking that we DO want them in the * schemaNodeMap, but not in the instanceDocument ... so we can remove them * from the instance document * * @param globalElementDef the GlobalElement type definition containing the sub group element * @param e current schema Element to process * @param parent instanceDoc Element to which we attach new instanceElement * @exception Exception if this element cannot be processed */ private void processSubstitutionGroup(GlobalElement globalElementDef, Element e, Element parent) throws Exception { prtln("\nprocessSubstitutionGroup()", 1); if (globalElementDef.isAbstract()) { prtln("\n\t ABSTRACT GLOBAL ELEMENT!\n", 1); } Iterator subGroup = globalElementDef.getSubstitutionGroup().iterator(); prtln("\t substitution group", 1); while (subGroup.hasNext()) { GlobalElement member = (GlobalElement) subGroup.next(); prtln("\n Substitution Member: " + member.getQualifiedInstanceName(), 1); Namespace memberNS = member.getNamespace(); prtln("\t namespace obtained from globalDef: " + NamespaceRegistry.nsToString(memberNS), 1); pushNS(memberNS); readerStack.push(member.getSchemaReader()); processSchemaElement(member.getElement(), parent); this.popNS(); readerStack.pop(); } } 开发者ID:NCAR,项目名称:joai-project,代码行数:35,代码来源:StructureWalker.java 示例8: register import org.dom4j.Namespace; //导入依赖的package包/类 /** * Register a namespace by placing itto the uriMap (mapping uri to its * namespace) and resets default namespaces so they will be recomputed using * updated uriMap. * * @param ns namespace to be registered */ public void register(Namespace ns) { // prtln ("registering namespace (" + ns.getPrefix() + ") " + ns.getURI()); prefixMap.put(ns.getPrefix(), ns); /* NOTE: this implementation of uriMap assumes that there will be only one namespace per uri, which is probably not safe. In particular, if we define a "namedDefaultNamespace" then we have two namespaces with the same uri. HOWEVER, this implementation allows us to assume that the namespace returned for a given uri is the last-registered namespace, and that is a nice property, e.g., when we register a namedDefaultNamespace, then we get this when we ask for the namespace assigned to it's uri, and this is what we count on in schema processing when we call "getSchemaNamespace()". */ String uri = ns.getURI(); Namespace existing = getNSforUri(uri); if (existing != NO_NAMESPACE) { // prtln ("\t NOTE: overwriting existing namespace with prefix: \"" + existing.getPrefix() + "\""); } uriMap.put(ns.getURI(), ns); // reset these namespaces, which will get recomputed when needed namedDefaultNamespace = null; defaultNamespace = null; } 开发者ID:NCAR,项目名称:joai-project,代码行数:33,代码来源:NamespaceRegistry.java 示例9: getInstanceQualifiedName import org.dom4j.Namespace; //导入依赖的package包/类 /** * Return globalDef from the globalDefMap after resolving the given typeName into a baseName and namespace. Returns null if namespace cannot be determined. NOTE: this can be refactored to use getInstanceQualifiedName (returned prefix must be resolved into a namespace before the call to globalDefMap.getValue (baseName, namespace) */ public GlobalDef getGlobalDef (String typeName) { // prtln ("getGlobalDef with " + typeName); Namespace namespace = targetNamespace; String prefix = null; String baseName = typeName; if (NamespaceRegistry.isQualified(typeName)) { baseName = NamespaceRegistry.stripNamespacePrefix(typeName); prefix = NamespaceRegistry.getNamespacePrefix(typeName); namespace = getNamespaces().getNSforPrefix(prefix); if (namespace == Namespace.NO_NAMESPACE) { prtln ("\nWARNING: getGlobalDef can't find namespace for \"" + prefix + "\""); prtln (this.namespaces.toString()); return null; } } return globalDefMap.getValue (baseName, namespace.getURI()); } 开发者ID:NCAR,项目名称:joai-project,代码行数:25,代码来源:SchemaReader.java 示例10: space import org.dom4j.Namespace; //导入依赖的package包/类 /** * Accessor method for retrieving a specific named GlobalDef. Namespace prefixes for the default name space (or the targetNameSpace if there is no defaultNamespace defined), are stripped. * *@param name Description of the Parameter *@return The value value */ public GlobalDef getValue(String name) { GlobalDef ret = null; if (NamespaceRegistry.isQualified(name)) { String prefix = NamespaceRegistry.getNamespacePrefix(name); String unqualifiedName = NamespaceRegistry.stripNamespacePrefix(name); Namespace ns = this.getNamespaces().getNSforPrefix(prefix); ret = this.getValue(unqualifiedName, ns); } else { ret = getValue(name, namespaces.getDefaultNamespace()); try { if (ret == null) { prtln ("GlobalDefMap failed to find " + name + " in the default namespace"); throw new Exception (); } } catch (Exception e) { e.printStackTrace(); } } return ret; } 开发者ID:NCAR,项目名称:joai-project,代码行数:30,代码来源:GlobalDefMap.java 示例11: toString import org.dom4j.Namespace; //导入依赖的package包/类 /** * String representation of the ModelGroup object * * @return a String representation of the ModelGroup object */ public String toString() { String s = "ModelGroup: " + getName(); String nl = "\n\t"; s += nl + "type: " + getType(); s += nl + "location: " + getLocation(); s += nl + "contentmodel: " + getContentModel(); if (getNamespace() != Namespace.NO_NAMESPACE) s += nl + "namespace: " + getNamespace().getPrefix() + ": " + getNamespace().getURI(); else s += nl + "namespace: null"; // s += nl + "modelGroup: " + modelGroup; // s += nl + "there are " + getChildren().size() + " content elements"; /* * if (modelGroup == null) * s += "\n" + element.asXML(); */ // s += Dom4jUtils.prettyPrint (getElement()); return s; } 开发者ID:NCAR,项目名称:joai-project,代码行数:25,代码来源:ModelGroup.java 示例12: getQualifiedAttributeName import org.dom4j.Namespace; //导入依赖的package包/类 /** * Gets the qualifiedAttributeName attribute of the Renderer object.

* * NOTE: i don't think this method is required at all. if the instance * document is constructed correctly, the attributes are already qualified as * needed and there is no need to mess with it any further .. * * @param name NOT YET DOCUMENTED * @param typeDef NOT YET DOCUMENTED * @param element NOT YET DOCUMENTED * @return The qualifiedAttributeName value */ protected String getQualifiedAttributeName(String name, Element element, GlobalDef typeDef) { Namespace typeDefNamespace = typeDef.getNamespace(); String typeDefNSPrefix = typeDefNamespace.getPrefix(); String qualifiedName = name; // if the name is qualified, remove namespace prefix if it is the same as // the typeDef's prefix if (NamespaceRegistry.isQualified(name)) { // get the namespace corresponding to the name's prefix - in the context of provided typeDef qualifiedName = resolveQualifiedName(name, typeDef); } else { // no prefix supplied String schemaPath = SchemaHelper.toSchemaPath(xpath); SchemaNode parentNode = sh.getSchemaNode(schemaPath); // when there is no prefix, don't qualify the attribute qualifiedName = name; } // prtln(" ... returning " + qualifiedName); return qualifiedName; } 开发者ID:NCAR,项目名称:joai-project,代码行数:37,代码来源:MdeNode.java 示例13: removeNamespaces import org.dom4j.Namespace; //导入依赖的package包/类 /** * Remove namespaces from element recursively. */ @SuppressWarnings("unchecked") public void removeNamespaces( Element elem ) { elem.setQName( QName.get( elem.getName(), Namespace.NO_NAMESPACE, elem.getQualifiedName() ) ); Node n; Iterator it = elem.elementIterator(); while ( it.hasNext() ) { n = it.next(); switch ( n.getNodeType() ) { case Node.ATTRIBUTE_NODE: ( (Attribute) n ).setNamespace( Namespace.NO_NAMESPACE ); break; case Node.ELEMENT_NODE: removeNamespaces( (Element) n ); break; } } } 开发者ID:ruikom,项目名称:apache-archiva,代码行数:27,代码来源:XMLReader.java 示例14: resolveQName import org.dom4j.Namespace; //导入依赖的package包/类 /** * Tries to resolve give QName into a "top-level" namespace and prefix. If the * there is no prefix and the namespace is the default namespace, assign the * NAMED defaultNamespace. * * @param qName Description of the Parameter * @return Description of the Return Value * @exception Exception Description of the Exception */ private QName resolveQName(QName qName) throws Exception { String prefix = qName.getNamespacePrefix(); String name = qName.getName(); String uri = qName.getNamespaceURI(); prtln("\n\t resolveQName: ", 1); prtln("\t\t name: " + name, 1); prtln("\t\t prefix: " + prefix, 1); prtln("\t\t uri: " + uri, 1); Namespace topLevelNS = namespaces.getNSforUri(uri); if (topLevelNS == null) { prtlnErr("ERROR: resolveQName could not find top-level namespace for " + uri); return null; } else if (topLevelNS == namespaces.getDefaultNamespace()) { topLevelNS = namespaces.getNamedDefaultNamespace(); } return DocumentHelper.createQName(name, topLevelNS); } 开发者ID:NCAR,项目名称:dls-repository-stack,代码行数:29,代码来源:StructureWalker.java 示例15: createChildElement import org.dom4j.Namespace; //导入依赖的package包/类 /** * Resolve qualified name against top-level namespace registry * * @param name NOT YET DOCUMENTED * @return NOT YET DOCUMENTED */ private Element createChildElement(String name) { prtln("\n createChildElement() name: " + name, 1); Namespace ns = getCurrentNamespace(); prtln("\t currentNamespace -- " + ns.getPrefix() + ": " + ns.getURI(), 1); Element child = null; if (ns == null || !namespaceEnabled) { child = DocumentHelper.createElement(name); } else { QName baseQName = DocumentHelper.createQName(name, ns); try { child = DocumentHelper.createElement(resolveQName(baseQName)); } catch (Exception e) { prtlnErr("createChildElement error: " + e.getMessage()); e.printStackTrace(); return null; } } prtln(" ... child: " + child.asXML(), 1); return child; } 开发者ID:NCAR,项目名称:dls-repository-stack,代码行数:28,代码来源:StructureWalker.java

注:本文中的org.dom4j.Namespace类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3